/**
 * 
 */
package com.android.weibogo;

import java.util.ArrayList;
import java.util.List;

import android.widget.BaseAdapter;


public abstract class WeiboModel {
	protected List<WeiboAdapter> adapterList;
	protected List<WeiboInfo> weiboList;
	protected String weiboName;
	protected String tokenKey;
	protected String tokenSecret;
	protected String customKey;
	protected String customSecret;
	/**
	 * @return the weiboName
	 */
	public String getWeiboName() {
		return weiboName;
	}
	/**
	 * @param weiboName the weiboName to set
	 */
	public void setWeiboName(String weiboName) {
		this.weiboName = weiboName;
	}
	/**
	 * @return the tokenKey
	 */
	public String getTokenKey() {
		return tokenKey;
	}
	/**
	 * @param tokenKey the tokenKey to set
	 */
	public void setTokenKey(String tokenKey) {
		this.tokenKey = tokenKey;
	}
	/**
	 * @return the tokenSecret
	 */
	public String getTokenSecret() {
		return tokenSecret;
	}
	/**
	 * @param tokenSecret the tokenSecret to set
	 */
	public void setTokenSecret(String tokenSecret) {
		this.tokenSecret = tokenSecret;
	}
	/**
	 * @return the customKey
	 */
	public String getCustomKey() {
		return customKey;
	}
	/**
	 * @param customKey the customKey to set
	 */
	public void setCustomKey(String customKey) {
		this.customKey = customKey;
	}
	/**
	 * @return the customSecrect
	 */
	public String getCustomSecrect() {
		return customSecret;
	}
	/**
	 * @param customSecrect the customSecrect to set
	 */
	public void setCustomSecrect(String customSecrect) {
		this.customSecret = customSecrect;
	}
	/**
	 * @return the weiboList
	 */
	public List<WeiboInfo> getWeiboList() {
		return weiboList;
	}
	
	public interface WeiboListChangeListener{
		void OnWeiboListChange(List<WeiboAdapter> adapterList);
	}
	
	private WeiboListChangeListener weiboListChangeLister;
	public void setWeiboListChangeListener(
			WeiboListChangeListener listener) {
		this.weiboListChangeLister = listener;
	}
	public interface TimeoutListener{
		void OnWeiboTimeout();
	}
	private TimeoutListener timeoutListener;
	public void setTimeoutListener(
			TimeoutListener listener) {
		this.timeoutListener = listener;
	}

    protected void notifyListener() {
        if (null != weiboListChangeLister) {
        	weiboListChangeLister.OnWeiboListChange(this.adapterList); 
        }
    }   
    protected void timeoutListener() {
        if (null != timeoutListener) {
        	timeoutListener.OnWeiboTimeout(); 
        }
    }
	/**
	 * @param weiboName
	 * @param tokenKey
	 * @param tokenSecret
	 * @param customKey
	 * @param customSecrect
	 */
	public WeiboModel(String weiboName, String tokenKey, String tokenSecret,
			String customKey, String customSecrect) {
		super();
		this.weiboName = weiboName;
		this.tokenKey = tokenKey;
		this.tokenSecret = tokenSecret;
		this.customKey = customKey;
		this.customSecret = customSecrect;
		this.weiboList = new ArrayList<WeiboInfo>();
	}
	/**
	 * get the latest weibo items(up to 10)
	 * @return the number of the latest weibo items
	 */
	public abstract int refreshHomeMsg();
	/**
	 * write a new weibo
	 * @param info
	 * @return true if writing new weibo succeed
	 */
	public abstract boolean newWeibo(String content, String pic);
	/**
	 * @param weiboId
	 * @param content
	 * @return true if casting weibo to somebody succeed
	 */
	public abstract boolean castTo(long weiboId, String content);
	/**
	 * @param userName
	 * @param weiboId
	 * @param someWords
	 * @return
	 */
	public abstract boolean appraise(String userName, long weiboId, String someWords);
	/**
	 * broadcast weibo to all peoples who are listening to, if modelList is not null
	 * it also broadcast the weibo to other weibo platform
	 * @param weiboId
	 * @param modelList - other weibo platform data model
	 * @return true if broadcast succeed
	 */
	public abstract boolean broadcast(long weiboId, List<WeiboModel> modelList);
}
